(ns com.yawmark.euler.clj.e87
    (:use com.yawmark.euler.clj.core))

(defn euler-87 [max]
  (count
    (into
      #{}
      (let [squares (map #(expt % 2) primes)
            cubes   (map #(expt % 3) primes)
            quads   (map #(expt % 4) primes)]
        (for [x (take-while #(< % max) squares)
                y (take-while #(< % (- max x)) cubes)
                z (take-while #(< % (- max x y)) quads)
                n [(+ x y z)]
                :when (< n max)]
             n)))))

